//
//  LSExponentCompanySponsorCell.m
//  LookScore
//
//  Created by wr on 2017/12/11.
//  Copyright © 2017年 ChongQingXunTiCompany. All rights reserved.
//

#define controlWidth ((LSScreenWidth -LSSpaceLeftWidth1)*0.6f)/3
#import "LSExponentCompanySponsorCell.h"

#import "LSExponentModel.h"
@interface LSExponentCompanySponsorCell()

@property(strong,nonatomic)NSMutableArray *scoreArray;

@property(strong,nonatomic)UILabel *companyLab;

@end
@implementation LSExponentCompanySponsorCell

-(NSMutableArray *)scoreArray{
    if (!_scoreArray) {
        _scoreArray=[NSMutableArray array];
    }
    return _scoreArray;
    
}
+(LSExponentCompanySponsorCell *)ExponentCompanySponsorTableviewCellByTableView:(UITableView *)tableView{
    LSExponentCompanySponsorCell *cell=[tableView dequeueReusableCellWithIdentifier:NSStringFromClass(self)];
    if (!cell) {
        cell=[[LSExponentCompanySponsorCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass(self)];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
    
        [self addContentView];
    }
    
    return self;
}

-(void)addContentView{
    
    UILabel *companyLab=[[UILabel alloc]init];
    companyLab.font=LSFontSize12;
    companyLab.textAlignment=NSTextAlignmentCenter;
    companyLab.textColor=LSTitleGrayColor1;
    [self.contentView addSubview:companyLab];
    self.companyLab=companyLab;
    companyLab.sd_layout.leftEqualToView(self.contentView).widthIs(64).topEqualToView(self.contentView).bottomEqualToView(self.contentView).offset(-8);
    
    UIView *lineView=[[UIView alloc]init];
    lineView.backgroundColor=LSSubColorf25e59;
    [self.contentView addSubview:lineView];
    lineView.sd_layout.leftSpaceToView(companyLab, 0).topEqualToView(companyLab).widthIs(2.f).heightIs(52);
    
    UIView *beginView=[[UIView alloc]init];
    beginView.backgroundColor=LSTitleWhiteColor;
    [self.contentView addSubview:beginView];
     beginView.sd_layout.leftSpaceToView(lineView, 0).topEqualToView(lineView).rightEqualToView(self.contentView).heightIs(lineView.centerY);
    
    UILabel *beginLab=[[UILabel alloc]init];
    beginLab.font=LSFontSize12;
    beginLab.text=@"初始";
    beginLab.textColor=LSNavMainColor;
    beginLab.textAlignment=NSTextAlignmentLeft;
    [beginView addSubview:beginLab];
    beginLab.sd_layout.leftEqualToView(beginView).offset(24).topEqualToView(beginView).widthIs(LSScreenWidth-90-LSSpaceLeftWidth1-(LSScreenWidth-LSSpaceLeftWidth1)*0.6f).bottomEqualToView(beginView);
    
    for (int b=0; b<3; b++) {
    
        UILabel *label=[[UILabel alloc]init];
        label.font=LSFontSize12;
        label.textAlignment=NSTextAlignmentCenter;
        label.textColor=LSTitleGrayColor2;
        [beginView addSubview:label];
        label.sd_layout.rightEqualToView(beginView).offset(-(controlWidth*b+LSSpaceLeftWidth1)).topEqualToView(beginView).bottomEqualToView(beginView).widthIs(controlWidth);
        
        [self.scoreArray addObject:label];
    }
    
    UIView *immediatelyView=[[UIView alloc]init];
    immediatelyView.backgroundColor=LSSubGrayColorf7;
    [self.contentView addSubview:immediatelyView];
    immediatelyView.sd_layout.leftSpaceToView(lineView, 0).topSpaceToView(beginView, 0).rightEqualToView(self.contentView).bottomEqualToView(lineView);
    
    UILabel *immediatelyLab=[[UILabel alloc]init];
    immediatelyLab.font=LSFontSize12;
    immediatelyLab.text=@"即时";
    immediatelyLab.textColor=LSSubColorf25e59;
    immediatelyLab.textAlignment=NSTextAlignmentLeft;
    [immediatelyView addSubview:immediatelyLab];
    immediatelyLab.sd_layout.leftEqualToView(immediatelyView).offset(24).topEqualToView(immediatelyView).widthIs(LSScreenWidth-90-LSSpaceLeftWidth1-(LSScreenWidth-LSSpaceLeftWidth1)*0.6f).bottomEqualToView(immediatelyView);
    
    for (int b=0; b<3; b++) {
        
        UILabel *label=[[UILabel alloc]init];
        label.font=LSFontSize12;
        label.textAlignment=NSTextAlignmentCenter;
        label.textColor=LSTitleGrayColor2;
        [immediatelyView addSubview:label];
        label.sd_layout
        .rightEqualToView(immediatelyView).offset(-(controlWidth*b+LSSpaceLeftWidth1))
        .topEqualToView(immediatelyView)
        .bottomEqualToView(immediatelyView)
        .widthIs(controlWidth);
        
        [self.scoreArray addObject:label];
    }
//   [self addFasleData];
    
}

- (void)setAiModel:(AIHistoricaDataList *)aiModel{
    
    _aiModel = aiModel;
    self.companyLab.text = aiModel.CompanyName;
    
    
    NSMutableArray * array = @[].mutableCopy;
    
    if (aiModel.companyData.count == 1) {
        companyData * model = aiModel.companyData.firstObject;
        [array addObjectsFromArray:@[model.HD_KD,model.HD_PK,model.HD_ZD,@"",@"",@""]];
    }else if (aiModel.companyData.count > 1){
        for (companyData * model in aiModel.companyData){
            if (model.State == 0) {
                [array addObjectsFromArray:@[model.HD_KD,model.HD_PK,model.HD_ZD]];
            }
        }
        companyData * model = aiModel.companyData.firstObject;
        [array addObjectsFromArray:@[model.HD_KD,model.HD_PK,model.HD_ZD]];
    }
    [self.scoreArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        UILabel * label = (UILabel *)obj;
        label.text = array[idx];
    }];
    
    
}


- (void)setOddModel:(OddsChangeRecordList *)oddModel{
    _oddModel = oddModel;
//    oddModel
    self.companyLab.text = oddModel.CompanyName;
    NSMutableArray * array = @[].mutableCopy;
    
    companyData * model = oddModel.companyData.firstObject;
    [array addObjectsFromArray:@[model.Odds_Negative,model.Odds_Flat,model.Odds_Win,@"",@"",@""]];
    
    [self.scoreArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        UILabel * label = (UILabel *)obj;
        label.text = array[idx];
    }];
    
    
}

- (void)setSdModel:(SDHistoricaDataList *)sdModel{
    
    _sdModel = sdModel;
     self.companyLab.text = sdModel.CompanyName;
    NSMutableArray * array = @[].mutableCopy;
    
    if (sdModel.companyData.count == 1) {
        companyData * model = sdModel.companyData.firstObject;
        [array addObjectsFromArray:@[model.HD_XQ,model.HD_PK,model.HD_DQ,@"",@"",@""]];
    }else if (sdModel.companyData.count > 1){
        for (companyData * model in sdModel.companyData){
            if (model.State == 0) {
                [array addObjectsFromArray:@[model.HD_XQ,model.HD_PK,model.HD_DQ]];
            }
        }
        companyData * model = sdModel.companyData.firstObject;
        [array addObjectsFromArray:@[model.HD_XQ,model.HD_PK,model.HD_DQ]];
    }
    
//    for (companyData * model in sdModel.companyData) {
//        if (sdModel.companyData.count == 1) {
//            [array addObjectsFromArray:@[model.HD_XQ,model.HD_PK,model.HD_DQ,@"",@"",@""]];
//        }else{
//            if (model.State == 0) {
//                [array addObjectsFromArray:@[model.HD_XQ,model.HD_PK,model.HD_DQ]];
//
//
//            }else if (model.State == 1){
//
//                [array addObjectsFromArray:@[model.HD_XQ,model.HD_PK,model.HD_DQ]];
//            }
//        }
//    }
    
    
    [self.scoreArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        UILabel * label = (UILabel *)obj;
        if (array.count<6) {
            if (idx<array.count) {
               label.text = array[idx];
            }
          
        }else{
            label.text = array[idx];
            
        }
        
    }];
}

-(void)addFasleData{
    
    
    self.companyLab.text=@"SA";
      NSArray *array=@[@"5.20",@"七半",@"5.20",@"5.20",@"5.20",@"5.20",@"5.20",@"5.20",@"5.20"];
    [self.scoreArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        UILabel *label=(UILabel *)obj;
        NSInteger int5=arc4random() % 6;
        NSInteger int6=arc4random() % 6;
        NSInteger int7=arc4random() % 6;
        label.text=array[idx];
        if(idx==4){
            label.textColor=LSSubColorf25e59;
            label.attributedText=[CommonClass setBasicTitle:@"*" homeTitle:@"" changeTitle:@"半/一" color:LSNavMainColor size:12 isBold:NO];
        }else if (idx==int5){
            label.textColor=LSSubColorf25e59;
        }else if (idx==int6){
            label.textColor=LSNavMainColor;
        }else if (idx==int7){
            label.textColor=RandColor;
        }
        
    }];
    
    
}



- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
